package uk.co.revisual.cmaps
{	
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.observer.Notifier;
	
	
	/**
	 * 
	 * @author revisual.co.uk
	 * 
	 * This is an abstract convenience class that allows commands to be registered 
	 * and removed as a convenient package.  Notification names can also be declared
	 * on subclasses.
	 */
	public class BaseCMap extends Notifier
	{
		/**
		 * the incoming notification 
		 */
		protected var note:INotification;
		
		/**
		 * 
		 * @param note the incoming notification
		 * 
		 */
		public function BaseCMap( note:INotification )
		{
			this.note = note;
			super();
		}
				
		/**
		 * override to register commands 
		 */
		public function occupy():void
		{
			
		}
		
		/**
		 * override to remove commands 
		 */
		public function vacate():void
		{
			
		}
		
		/**
		 * Allows a Command to be executed from its Class referance. 
		 * @param cmdClass
		 * @param note
		 * 
		 */
		protected final function subexecute( cmdClass:Class, note:INotification ):void{
			var c:ICommand = ICommand(  new cmdClass() );
			c.initializeNotifier( multitonKey );
			c.execute( note );
		}
	}
}